<?php
/**
 * Created by PhpStorm.
 * User: happy
 * Date: 19/4/19
 * Time: 下午9:55
 * coroutine 示例 ,从ppt上获取
 */
//说明协程内部也可以嵌套协程
$socket=new Swoole\Coroutine\Socket(AF_INET,SOCK_STREAM,0);
 $socket->bind('0.0.0.0',8900);
 $socket->listen(128);
go(function()use($socket){
    while(true){
            $client=$socket->accept();
            go(function() use ($client){
                $data=$client->recv();
                $client->send('server receive'.$data);

        });
     }
});

